package com.zgroup.domain

class InfoPicture implements Comparable {

    String fileName
    InfoRelease info
    Date dateCreated
    String title
    String summary
    String showFlag = '1'  // 显示标记位 1：显示 0：不显示
    String approveFlag = '1'  // 审批通过标记 0:审核中 1：通过  2:不通过

    static transients = ['fileFullName', 'thumbFullName']

    int compareTo(obj) {
        dateCreated.compareTo(obj.dateCreated)
    }

    static constraints = {
        fileName(maxSize: 50)
        info(nullable: true)
        title(nullable: true,maxSize: 50)
        summary(nullable: true,maxSize: 255)
        approveFlag(maxSize: 6)
        showFlag(maxSize: 6)
    }

    static mapping = {
        cache true
        dynamicInsert true
        dynamicUpdate true
    }

    String getFileFullName() {
        return InfoRelease.UPLOAD_FILE_PATH + info.id + "/" + fileName
    }

    String getThumbFullName() {
        return InfoRelease.UPLOAD_THUMBNAIL_PATH + info.id + "/" + fileName
    }

    String toString() {
        "id:" + id
    }
}
